﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace AgvSystem.Web.Charge_Record
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				#warning 代码生成提示：显示页面,请检查确认该语句是否正确
				ShowInfo();
			}
		}
			
	private void ShowInfo()
	{
		AgvSystem.BLL.Charge_Record bll=new AgvSystem.BLL.Charge_Record();
		AgvSystem.Model.Charge_Record model=bll.GetModel();
		this.txtAgv_Num.Text=model.Agv_Num.ToString();
		this.txtBegin_Time.Text=model.Begin_Time.ToString();
		this.txtEnd_Time.Text=model.End_Time.ToString();
		this.txtCharge_Flag.Text=model.Charge_Flag.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtAgv_Num.Text))
			{
				strErr+="Agv_Num格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtBegin_Time.Text))
			{
				strErr+="Begin_Time格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtEnd_Time.Text))
			{
				strErr+="End_Time格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtCharge_Flag.Text))
			{
				strErr+="Charge_Flag格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int Agv_Num=int.Parse(this.txtAgv_Num.Text);
			DateTime Begin_Time=DateTime.Parse(this.txtBegin_Time.Text);
			DateTime End_Time=DateTime.Parse(this.txtEnd_Time.Text);
			int Charge_Flag=int.Parse(this.txtCharge_Flag.Text);


			AgvSystem.Model.Charge_Record model=new AgvSystem.Model.Charge_Record();
			model.Agv_Num=Agv_Num;
			model.Begin_Time=Begin_Time;
			model.End_Time=End_Time;
			model.Charge_Flag=Charge_Flag;

			AgvSystem.BLL.Charge_Record bll=new AgvSystem.BLL.Charge_Record();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
